﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class chongzhi1 : System.Web.UI.Page
{
     WebService.emoneybusiness service = new WebService.emoneybusiness();
    //emoneybusiness_test.emoneybusiness service = new emoneybusiness_test.emoneybusiness();
    protected void Page_Load(object sender, EventArgs e)
    {

    }
   
    protected void btnOK_mobile_Click(object sender, EventArgs e)//手机操盘手网上充值
    {
        string mob = mobile.Value.Trim();
        int mobpwd = int.Parse(mobile_pwd.Value);
        string cardid = cardId_mobile.Value.Trim();
        string cardpwd = cardPwd_mobile.Value.Trim();
        if (Session["code"] == null)
        {
            return;
        }
        string c = (string)Session["code"];
        string code = codemobile.Value.Trim();
        if (code.Trim().ToLower() == c.Trim())
        {
            try
            {
                
                string result = service.DOMobileAddFee(mob, mobpwd, cardid, cardpwd);
                ClientScript.RegisterStartupScript(GetType(), "a", "alert('" + result + "');", true);
                mobile_pwd.Value = "";
                cardPwd_mobile.Value = "";
                codemobile.Value = "";
            }
            catch (Exception ex)
            {
                ClientScript.RegisterStartupScript(GetType(), "a", "alert('服务器忙，请重试');", true);
            }

        }
        else
        {
            codemobile.Value = "";
            ClientScript.RegisterStartupScript(GetType(), "a", "alert('验证码输入不正确');", true);
        }
    }
    protected void btnOk_pc_Click(object sender, EventArgs e)//pc版本
    {
        string username = userName_pc.Value.Trim();
        string softpwd = softPwd_pc.Value.Trim();
        string cardid = cardId_pc.Value.Trim();
        string cardpwd = cardPwd_pc.Value.Trim();
        string c = codepc.Value.Trim();
        int cardType = 1;     //leixing 
        if (sLeve.Checked)
            cardType = int.Parse(sLeve.Value);
        else if (hLeve.Checked)
            cardType = int.Parse(hLeve.Value);
        else
            cardType = 0;
        string code = (string)Session["code"];
        if (c.Trim().ToLower() == code.Trim())
        {
            if (!service.CheckUserName(username, softpwd))
            {
                ClientScript.RegisterStartupScript(GetType(), "a", "alert('充值失败,软件用户名或密码有误');", true);
            }
            else
            {
                string result = service.DOUserAddFeeNew(username, cardType, cardid, cardpwd);
                ClientScript.RegisterStartupScript(GetType(), "a", "alert('" + result + "');", true);
                softPwd_pc.Value= "";
                cardPwd_pc.Value = "";
                codepc.Value= "";
            }
        }
        else
        {
            codepc.Value = "";
            ClientScript.RegisterStartupScript(GetType(), "a", "alert('验证码输入不正确');", true);
        }
    }
    protected void btn_mobileHG_submit_Click(object sender, EventArgs e)
    {

        string username = mobileHG_username.Value.Trim();
        string pwd = mobileHG_password.Value.Trim();
        string cardnum = mobileHG_cardnum.Value.Trim();
        string cardpwd = mobileHG_cardpass.Value.Trim();
        string code = this.mobileHG_code.Value.Trim();
        if (Session["code"] == null || Session["pc_username"] == null || Session["pc_userpwd"]==null)
        {
            return;
        }
        string c = (string)Session["code"];
        string pc_username = Session["pc_username"].ToString();
        string pc_userpwd = Session["pc_userpwd"].ToString();
        if (c.Trim().ToLower() == code.Trim())
        {
            try
            {
                //方法
                
                string result = service.DOMobileAddFee1(username, int.Parse(pwd), cardnum, cardpwd, pc_username, pc_userpwd);
                ClientScript.RegisterStartupScript(GetType(), "a", "alert('" + result + "');", true);

                mobileHG_cardpass.Value= "";
                mobileHG_code.Value= "";
                mobileHG_password.Value= "";
            }
            catch (Exception ex)
            {
                ClientScript.RegisterStartupScript(GetType(), "a", "alert('服务器忙，请稍后再试');", true);
            }
        }
        else
        {
            mobileHG_code.Value= "";
            ClientScript.RegisterStartupScript(GetType(), "a", "alert('验证码输入不正确');", true);
        }
    }
}